<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<title>信息录入</title>
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<link rel="stylesheet" href="drive_information.css">
	<link rel="stylesheet" href="normalize.css">
	<link rel="stylesheet" href="../public_css/public_header.css">
</head>
<body>
<header class=" public_header">

	<div class="public_header_return">
	    <img src="../public_img/return.png" alt="" class="public_header_return" onclick="history.back(-1)">
	    <p>试驾信息</p>
	</div>
</header>
<section class="mainbody">
	<form class="information_collect">
		<span>居住地址:</span>
		<input class="message_input" type="text"  id="address" name="address" placeholder="请输入正确的地址">
		<br/>
		<span>试驾时间:</span>
		<input class="message_input"  type="text" name="trytime" id="trytime"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" >
		<br/>
		<input class="submit_final" type="button" value="提交" id="button">
	<!--	<input class="contact_server" type="button" value="联系客服">-->
	</form>
</section>
<script src="jquery.min.js"></script>
<script src="picturefill.js"></script>
<script src="../layer.js"></script>
<script src="laydate/laydate.js"></script>
<script >

		$("#button").click(function(){
			var address = $("#address").val();
			if(address==""){
				layer.msg("请填写正确的地址");
			}
			var trytime = $("#trytime").val();
			if(trytime==""){
				layer.msg("请填写试驾时间");
			}
			var token =localStorage.phone;
			$.ajax({
				url:"https://newapp.icandrive.cn/api/testDrive.php",
				type:'post',
				dataType:'json',
				data:{address:address,time:trytime,token:token},
				success:function(data){
					if(data.status==200){
						layer.msg("试驾预约成功");
						setInterval(function(){
							window.location.href="../index/index.html";
						},2000);
					}
					if(data.status==250){
						layer.msg("请重新登录");
						setInterval(function(){
							window.location.href="../login/log_in.html";
						},2000);
					}
					if(data.status==400){
						layer.msg("申请失败请重新申请");

					}
					if(data.status==450){
						layer.msg("你已经申请过试驾了");
						setInterval(function(){
							window.location.href="../index/index.html";
						},2000);
					}
				},
				error:function(){
					 layer.msg('系统维护中',function(){
                                history.go(0)
                            },1000);
				}
			});

		});
</script>

    <script>
    document.addEventListener("plusready", function() {
        // 注册返回按键事件
        plus.key.addEventListener('backbutton', function() {
            window.history.back();
        }, false);
        //此处false代表不退出页面，如果为true回退到上一个一面
    });
</script>
</body>
</html>
